package test.base.kv;

import hyl.base.kv.cache.KvCacheSS;
import hyl.base.kv.cache.KvExCacheSS;
import hyl.core.MyDate;
import hyl.core.MyFun;
import hyl.core.run.MyRun;

public class demokv {
	public static void main(String[] args) {
		MyRun mr=	MyRun.getInstance("团",6);
		mr.execute( ()->{
			test() ;
		});
		mr.execute( ()->{
			testex1() ;
		});
		mr.execute( ()->{
			testex2() ;
		});
	}

	public static void test() {
		KvCacheSS co2 = new KvCacheSS("微服务库", "终端1");
		co2.clear();
		co2.put("tk3", "value3");
		co2.put("tk4", "value4");
		System.out.println(co2.get("tk1"));
		co2.do遍历((k, v) -> {
			MyFun.print(MyFun.bytes2U8str(k), MyFun.bytes2U8str(v));
			return false;
		});
		MyDate.sleeps(3);
		co2.do遍历((k, v) -> {
			MyFun.print(MyFun.bytes2U8str(k), MyFun.bytes2U8str(v));
			return false;
		});
	}

	public  static void testex1() {
		KvExCacheSS co2 = new KvExCacheSS("微服务库", "终端", 5000);
		co2.clear();
		co2.put("tk1", "value1");
		co2.put("tk2", "value2");
//	 System.out.println(co2.get("tk1"));
		co2.do遍历S((k, v) -> {
			MyFun.print(k, v.getValue());
			return false;
		});
		MyDate.sleeps(3);
		co2.do遍历S((k, v) -> {
			MyFun.print(k, v.getValue());
			return false;
		});
		MyDate.sleeps(3);
		co2.do遍历S((k, v) -> {
			MyFun.print(k, v.getValue());
			return false;
		});
	}

	public static void testex2() {
		KvExCacheSS co2 = new KvExCacheSS("微服务库", "终端2", 5000);
		co2.clear();
		co2.put("tk111", "value111");
		co2.put("tk121", "value121");
//	 System.out.println(co2.get("tk1"));
		co2.do遍历S((k, v) -> {
			MyFun.print(k, v.getValue());
			return false;
		});
		MyDate.sleeps(3);
		co2.do遍历S((k, v) -> {
			MyFun.print(k, v.getValue());
			return false;
		});
		MyDate.sleeps(3);
		co2.do遍历S((k, v) -> {
			MyFun.print(k, v.getValue());
			return false;
		});
	}
}
